{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d20767aa-def3-4e50-b194-9e327b523b04",
   "metadata": {},
   "source": [
    "# Exercise: Time Series Manipulations in Pandas\n",
    "\n",
    "Like in prior exercises, you'll download a ticker's historical data from YahooFinance. But raw data isn't that useful by itself, so in this exercise you'll get practice with manipulating time series data in Pandas. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "43a37184-44e1-41e2-a8b9-d776b56a92d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import yfinance as yf"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71fb6221-5044-43c9-bf58-c361cc16a2b0",
   "metadata": {},
   "source": [
    "**Pull data for your favorite ticker from YahooFinance**\n",
    "\n",
    "Use the YF API to pull **daily** price data for at least 3 years for any stock ticker you'd like."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c4b0b596-a1e0-4189-ae46-377a6c64da75",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_ticker = ''\n",
    "start_date = '' # use format YYYY-MM-DD\n",
    "end_date = ''\n",
    "\n",
    "data = yf.download( ... ) # replace ... inside this function with the correct parameters in order to get your data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13086f04-973b-4199-a932-5fb3945b8879",
   "metadata": {},
   "source": [
    "**Resample from daily to weekly, taking the Friday price**\n",
    "\n",
    "Using the above data, resample your `closing` price to weekly. In the demo, we used the last day of the period. In this exercise, can you figure out how to pull the weekly data that's for Friday specifically? "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "190edac7-7198-44f5-bde6-3cea8a78486a",
   "metadata": {},
   "outputs": [],
   "source": [
    "weekly_data_friday = ... #replace the ... "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b420bc1-c4e8-4425-bd68-d3ea6dcdea5e",
   "metadata": {},
   "source": [
    "**Taking time-based slice of your data**\n",
    "\n",
    "Above you pulled the last 3 years of data for a given ticker. But in lots of trading applications, you don't need data that goes that far back in time as trends and underlying phenomenon have changed. \n",
    "\n",
    "Can you take just the last 3 months of data and put it into a new DataFrame? "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e1779d06-cbbc-4b08-9af6-c3e874c90057",
   "metadata": {},
   "outputs": [],
   "source": [
    "last_3_months = "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
